package com.Servlet;

import com.Service.Impl.Okayapi_goodsServiceImpl;
import com.Service.Okayapi_goodsService;
import com.entity.Okayapi_goods;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author: 冷俊杰
 * @Description: 添加商品
 * @DateTime: 2022/6/22 9:36
 **/
@WebServlet(name = "/insertGoods", value = "/insertGoods")
public class insertGoods extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        Okayapi_goodsService service = new Okayapi_goodsServiceImpl();
        String goods_name = request.getParameter("goods_name");
        String goods_desc = request.getParameter("goods_desc");
        Integer goods_price = Integer.parseInt(request.getParameter("goods_price"));
        String goods_img = request.getParameter("goods_img");
        String gimgO = request.getParameter("gimgO");
        String gimgT = request.getParameter("gimgT");
        String gimgS = request.getParameter("gimgS");
        service.insertGoods(new Okayapi_goods(goods_name, goods_desc, goods_price, goods_img, gimgO, gimgT, gimgS));
        request.getRequestDispatcher("./PublishProduct.jsp").forward(request, response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }
}
